package net.mysoft.framework.base;

import java.util.List;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import net.mysoft.budgetsoft.system.pagemodel.DictionaryDetail;
import net.mysoft.budgetsoft.system.pagemodel.DictionaryType;
import net.mysoft.budgetsoft.system.service.DictionaryDetailService;
import net.mysoft.budgetsoft.system.service.DictionaryTypeService;
import net.mysoft.framework.cache.CacheManager;

import org.apache.log4j.Logger;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

public class SysInitListener implements ServletContextListener {
	
	private static final Logger logger = Logger.getLogger(SysInitListener.class);
	
	public void contextDestroyed(ServletContextEvent arg0) {

	}

	public void contextInitialized(ServletContextEvent event) {
		
		//System.out.println(IpUtil.class.getResource("/").getPath()); 
		
		logger.info("**********************************系统初始化监听器******************************************");
		
//		ServletContext scontext = event.getServletContext();      
//	    WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(scontext);   
//	    DictionaryDetailService dictionaryDetailService = (DictionaryDetailService)wac.getBean("dictionaryDetailService");
//	    DictionaryTypeService dictionaryTypeService = (DictionaryTypeService)wac.getBean("dictionaryTypeService");
//	    DictionaryType dt = new DictionaryType();
//	    List<DictionaryType> dtList = dictionaryTypeService.find(dt);
//	    for(DictionaryType type:dtList){
//		    DictionaryDetail dd = new DictionaryDetail();
//		    dd.setTypeID(type.getTypeID());
//		    CacheManager.putContent(type.getTypeID(), dictionaryDetailService.find(dd)); //放进缓存中
//	    }
	}

}
